<div class="tmd-doc">
<h1 class="tmd-header-1">
Concurrency Synchronization Overview
</h1>
<p></p>
<div class="tmd-usual">
This article will explain what are synchronizations and list the synchronization techniques supported by Go.
</div>
<p></p>
<h3 class="tmd-header-3">
What Are Concurrency Synchronizations?
</h3>
<p></p>
<div class="tmd-usual">
Concurrency synchronizations means how to control concurrent computations (a.k.a., goroutines in Go)
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
to avoid data races between them,
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
to avoid them consuming CPU resources when they have nothing to do.
</div>
</li>
</ul>
<p></p>
<p></p>
<h3 class="tmd-header-3">
What Synchronization Techniques Does Go Support?
</h3>
<p></p>
<div class="tmd-usual">
The article <a href="channel.html">channels in Go</a> has shown that we can use channels to do synchronizations. Besides using channels, Go also supports several other common synchronization techniques, such as mutex and atomic operations. Please read the following articles to get how to do synchronizations with all kinds of techniques in Go:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
<a href="channel-use-cases.html">Channel Use Cases</a>
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
<a href="channel-closing.html">How to Gracefully Close Channels</a>
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
<a href="concurrent-synchronization-more.html">Concurrency Synchronization Techniques Provided in the <code class="tmd-code-span">sync</code> Standard Package</a>
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
<a href="concurrent-atomic-operation.html">Atomic Operations Provided in the <code class="tmd-code-span">sync/atomic</code> Standard Package</a>
</div>
</li>
</ul>
<p></p>
<div class="tmd-usual">
We can also do synchronizations by making use of network and file IO. But such techniques are very inefficient within a single program process. Generally, they are used for inter-process and distributed synchronizations. Go 101 will not cover such techniques.
</div>
<p></p>
<div class="tmd-usual">
To understand these synchronization techniques better, it is recommended to know the <a href="memory-model.html">memory order guarantees in Go</a>.
</div>
<p></p>
<div class="tmd-usual">
The data synchronization techniques in Go will not prevent programmers from writing <a href="concurrent-common-mistakes.html">improper concurrent code</a>. However these techniques can help programmers write correct concurrent code easily. And the unique channel related features make concurrent programming flexible and enjoyable.
</div>
<p></p>
<p></p>
</div>
